package com.tanglongan.concurrent._basic;

public class Demo25 {
    public static void main(String[] args) throws InterruptedException {
        Thread t = new Demo25Thread();
        t.setDaemon(true);// 把线程设置为守护线程。主线程结束时，守护线程也就结束了
        t.start();
        Thread.sleep(3000);
        System.out.println("主线程结束");
    }
}

class Demo25Thread extends Thread {
    @Override
    public void run() {
        try {
            while (true) {
                System.out.println("time=" + System.currentTimeMillis());
                Thread.sleep(1000);
            }
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    }
}
